<?php $this->load->view('common/header');?>
<body class="padding_top">
<!-- head [[-->
<div class="head_box">
	<div class="bank_nav">
        <a href="<?php echo $back_url;?>"><i class="ico"></i></a>
    </div>
    <div class="add_nav">
    	<a href="<?php echo site_url('member/addressadd') ?>"><i class="ico"></i>新增</a>
    </div>
    <div class="head_title">收货地址</div>
</div>
<!--]] head -->
<!-- info [[-->
<div class="user_address">
	<ul>
        <?php if($dress){ ?>
            <?php foreach ($dress as $key => $val) {?>
                <li id="fav_box_<?php echo $val['dress_id']; ?>">
                    <?php if($val['dress_type'] == 1){?>
                        <a class="one on" href="#" >默认地址<i class="ico">&nbsp;</i></a>
                    <?php }else {?>
                        <a href="javascript:is_dress('#fav_box_<?php echo $val['dress_id']; ?>','<?php echo $val['dress_id']; ?>')" class="one <?php if($val['dress_type'] == 1) echo 'on'  ?>" >设为默认地址<i class="ico">&nbsp;</i></a>
                        <a class="one deldress on" href="javascript:del_dress('#fav_box_<?php echo $val['dress_id']; ?>','<?php echo $val['dress_id']; ?>')" >删除地址</a>
                    <?php } ?>

                    <p><?php echo $val['dress_uname']?> <?php echo $val['dress_utel']?></p>
                    <span><?php echo $val['dress_city'];?></span>
                    <span><?php echo $val['dress_udress']?></span>

                </li>
            <?php } ?>
        <?php }else {?>
            <div class="no_data">
                <i></i>
                <p>您暂时还没有收货地址哦~</p>
            </div>
        <?php } ?>
    </ul>
</div>
<script type="text/javascript">
    function is_dress(sec,dress_id){
        $.ajax({
            type : "post",
            url: baseurl+"index.php/dress/dress",
            data: {'dress_id':dress_id},
            dataType:"JSON",
            success: function (msg){
                if(msg.status==1){
                    layer.msg(msg.info);
                    $(sec).children("a").addClass('on').siblings().children("a").removeClass('on');
                    window.location.href=window.location.href;
                }
            }
        })
    }
    function del_dress(sec,dress_id){
        $.ajax({
            type : "post",
            url: baseurl+"index.php/dress/del_dress",
            data: {'dress_id':dress_id},
            dataType:"JSON",
            success: function (msg){
                if(msg.status==1){
                    layer.msg(msg.info);
                    window.location.href=window.location.href;

                }
            }
        })
    }

</script>
<!--]] info -->
</body>
</html>
